<template>
  <slash-panel>
    <slash-panel-header title="应用管理" />
<!--    <n-button @click="onTest">文件上传测试</n-button>-->

    <sys-app-list />
  </slash-panel>
</template>

<script lang="ts">
import { SlashPanel, SlashPanelBody, SlashPanelHeader } from "../../components/Panel/index";
import {http as api} from "@/api/index";
import SysAppList from "./SysAppList.vue";
import { Layer } from "slash-layer";

export default {
  name: "SysAppEntry",
  components: { SysAppList, SlashPanelBody, SlashPanelHeader, SlashPanel },
  setup(){
     const doUploadHeadImg = async (data: [any]) => {
      const formData = new FormData();
      for (const it of data) {
        formData.append("file", it);
      }
      formData.append("uploadPath", "user/headImg")
      return api.doUpload(null, formData);
    }
    async function onTest(){
      const file: any = await Layer.selectFile({
        accept: [".jpg", ".png", ".jpge"]
      })
      if(file.length==0)
      {
        Layer.error("请选择一张图片");
        return;
      }
     await doUploadHeadImg([file[0]]);
    }
    return{
      onTest
    }
  }
};

function onTest() {
    throw new Error("Function not implemented.");
}
</script>

<style scoped>

</style>
